package inits

import (
	"github.com/spf13/pflag"
	"redis_global_key/cache"
	"redis_global_key/config"
	"redis_global_key/models"
)

var (
	configPath = pflag.StringP("config", "c", "/Users/wanghongwei/GolandProjects/redis_global_key/cmd/config.yaml", "config file path.")
)

func Init() {

	pflag.Parse()
	// init config
	config.InitGlobalConfig(configPath)
	// init Redis
	errRedis := cache.Init(cache.StandaloneClientMode)
	if errRedis != nil {
		panic(errRedis)
	}
	// init DB
	models.DB.Init()
}
